package com.zxbit.uangstore.main;

import android.content.Intent;
import android.view.KeyEvent;
import android.view.WindowManager;

import com.zxbit.uangstore.R;
import com.zxbit.uangstore.base.BaseActivity;

import java.util.Timer;
import java.util.TimerTask;

public class SplashActivity extends BaseActivity {

    @Override
    protected void onUIReady() {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);// 全屏显示
        //透明状态栏
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        //透明导航栏
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        jumpToMain();

    }

    private void jumpToMain() {
        Timer timer = new Timer();
        TimerTask timerTask = new TimerTask() {
            @Override
            public void run() {
                Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);

                SplashActivity.this.startActivity(mainIntent);
                overridePendingTransition(R.anim.anim_in, R.anim.anim_out);
                finish();
            }
        };

        timer.schedule(timerTask, 1500);
    }

    @Override
    protected void initViews() {}

    @Override
    protected int getContentResId() {
        return R.layout.layout_of_splash;
    }

    @Override
    protected int getResId() {
        return 0;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
